/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package de.jadehs.cosima.impl;

import de.jadehs.cosima.*;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.impl.EFactoryImpl;
import org.eclipse.emf.ecore.plugin.EcorePlugin;

import de.jadehs.cosima.ANDExpression;
import de.jadehs.cosima.CharExpression;
import de.jadehs.cosima.Cosima;
import de.jadehs.cosima.CosimaFactory;
import de.jadehs.cosima.CosimaPackage;
import de.jadehs.cosima.Grammar;
import de.jadehs.cosima.KleeneExpression;
import de.jadehs.cosima.Loop;
import de.jadehs.cosima.Machine;
import de.jadehs.cosima.MoveTapeLeft;
import de.jadehs.cosima.MoveTapeRight;
import de.jadehs.cosima.MultiState;
import de.jadehs.cosima.ORExpression;
import de.jadehs.cosima.ReadFromTape;
import de.jadehs.cosima.Regex;
import de.jadehs.cosima.Stack;
import de.jadehs.cosima.State;
import de.jadehs.cosima.StatesRegister;
import de.jadehs.cosima.StringExpression;
import de.jadehs.cosima.Tape;
import de.jadehs.cosima.Transition;
import de.jadehs.cosima.TransitionsTable;
import de.jadehs.cosima.Turing;
import de.jadehs.cosima.While;
import de.jadehs.cosima.WriteToTape;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class CosimaFactoryImpl extends EFactoryImpl implements CosimaFactory {
	/**
	 * Creates the default factory implementation.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static CosimaFactory init() {
		try {
			CosimaFactory theCosimaFactory = (CosimaFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.jade-hs.de/cosima"); 
			if (theCosimaFactory != null) {
				return theCosimaFactory;
			}
		}
		catch (Exception exception) {
			EcorePlugin.INSTANCE.log(exception);
		}
		return new CosimaFactoryImpl();
	}

	/**
	 * Creates an instance of the factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public CosimaFactoryImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EObject create(EClass eClass) {
		switch (eClass.getClassifierID()) {
			case CosimaPackage.COSIMA: return createCosima();
			case CosimaPackage.MACHINE: return createMachine();
			case CosimaPackage.TAPE: return createTape();
			case CosimaPackage.STACK: return createStack();
			case CosimaPackage.STATES_REGISTER: return createStatesRegister();
			case CosimaPackage.STATE: return createState();
			case CosimaPackage.TRANSITIONS_TABLE: return createTransitionsTable();
			case CosimaPackage.REGEX: return createRegex();
			case CosimaPackage.GRAMMAR: return createGrammar();
			case CosimaPackage.LOOP: return createLoop();
			case CosimaPackage.WHILE: return createWhile();
			case CosimaPackage.TRANSITION: return createTransition();
			case CosimaPackage.TURING: return createTuring();
			case CosimaPackage.OR_EXPRESSION: return createORExpression();
			case CosimaPackage.KLEENE_EXPRESSION: return createKleeneExpression();
			case CosimaPackage.CHAR_EXPRESSION: return createCharExpression();
			case CosimaPackage.AND_EXPRESSION: return createANDExpression();
			case CosimaPackage.STRING_EXPRESSION: return createStringExpression();
			case CosimaPackage.MULTI_STATE: return createMultiState();
			case CosimaPackage.READ_FROM_TAPE: return createReadFromTape();
			case CosimaPackage.WRITE_TO_TAPE: return createWriteToTape();
			case CosimaPackage.MOVE_TAPE_LEFT: return createMoveTapeLeft();
			case CosimaPackage.MOVE_TAPE_RIGHT: return createMoveTapeRight();
			default:
				throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object createFromString(EDataType eDataType, String initialValue) {
		switch (eDataType.getClassifierID()) {
			case CosimaPackage.STATE_TYPE:
				return createStateTypeFromString(eDataType, initialValue);
			default:
				throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String convertToString(EDataType eDataType, Object instanceValue) {
		switch (eDataType.getClassifierID()) {
			case CosimaPackage.STATE_TYPE:
				return convertStateTypeToString(eDataType, instanceValue);
			default:
				throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Cosima createCosima() {
		CosimaImpl cosima = new CosimaImpl();
		return cosima;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Machine createMachine() {
		MachineImpl machine = new MachineImpl();
		return machine;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Tape createTape() {
		TapeImpl tape = new TapeImpl();
		return tape;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Stack createStack() {
		StackImpl stack = new StackImpl();
		return stack;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public StatesRegister createStatesRegister() {
		StatesRegisterImpl statesRegister = new StatesRegisterImpl();
		return statesRegister;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public State createState() {
		StateImpl state = new StateImpl();
		return state;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TransitionsTable createTransitionsTable() {
		TransitionsTableImpl transitionsTable = new TransitionsTableImpl();
		return transitionsTable;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Regex createRegex() {
		RegexImpl regex = new RegexImpl();
		return regex;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Grammar createGrammar() {
		GrammarImpl grammar = new GrammarImpl();
		return grammar;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Loop createLoop() {
		LoopImpl loop = new LoopImpl();
		return loop;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public While createWhile() {
		WhileImpl while_ = new WhileImpl();
		return while_;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Transition createTransition() {
		TransitionImpl transition = new TransitionImpl();
		return transition;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Turing createTuring() {
		TuringImpl turing = new TuringImpl();
		return turing;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ORExpression createORExpression() {
		ORExpressionImpl orExpression = new ORExpressionImpl();
		return orExpression;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public KleeneExpression createKleeneExpression() {
		KleeneExpressionImpl kleeneExpression = new KleeneExpressionImpl();
		return kleeneExpression;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public CharExpression createCharExpression() {
		CharExpressionImpl charExpression = new CharExpressionImpl();
		return charExpression;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ANDExpression createANDExpression() {
		ANDExpressionImpl andExpression = new ANDExpressionImpl();
		return andExpression;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public StringExpression createStringExpression() {
		StringExpressionImpl stringExpression = new StringExpressionImpl();
		return stringExpression;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MultiState createMultiState() {
		MultiStateImpl multiState = new MultiStateImpl();
		return multiState;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ReadFromTape createReadFromTape() {
		ReadFromTapeImpl readFromTape = new ReadFromTapeImpl();
		return readFromTape;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public WriteToTape createWriteToTape() {
		WriteToTapeImpl writeToTape = new WriteToTapeImpl();
		return writeToTape;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MoveTapeLeft createMoveTapeLeft() {
		MoveTapeLeftImpl moveTapeLeft = new MoveTapeLeftImpl();
		return moveTapeLeft;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MoveTapeRight createMoveTapeRight() {
		MoveTapeRightImpl moveTapeRight = new MoveTapeRightImpl();
		return moveTapeRight;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public StateType createStateTypeFromString(EDataType eDataType, String initialValue) {
		StateType result = StateType.get(initialValue);
		if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertStateTypeToString(EDataType eDataType, Object instanceValue) {
		return instanceValue == null ? null : instanceValue.toString();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public CosimaPackage getCosimaPackage() {
		return (CosimaPackage)getEPackage();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @deprecated
	 * @generated
	 */
	@Deprecated
	public static CosimaPackage getPackage() {
		return CosimaPackage.eINSTANCE;
	}

} //CosimaFactoryImpl
